<?php
/*
 * Created on 16.8.2011
 */
 
defined('_JEXEC') or die('Restricted access');

jimport('joomla.plugin.plugin');
require_once JPATH_SITE.DS.'components'.DS.'com_sef'.DS.'joomsef.php';

class plgContentJoomSEF extends JPlugin {
	function __construct(&$subject,$config) {
		parent::__construct($subject,$config);	
	}
	
	function onContentAfterSave($context,&$item,$isNew) {	
		$context=explode(".",$context);
		$option=$context[0];
			
		if($option=='com_categories' && strlen(($extension=JRequest::getString('extension',''))!='')) {
			$option=$extension;
		}
		
		$sef=JoomSEF::getInstance();
		if($isNew==false) {
			$sef->_checkURLs($option,$item);
		}
	}
	
	function onContentAfterDelete($context,$item) {
		$context=explode(".",$context);
		$option=$context[0];
		
		JoomSEF::_removeURL($option,$item);
	}
} 
?>